<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:insert="~{include :: header('讲师控制台')}" />
    <th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<body class="hold-transition">
<div class="container-fluid mt-2 mb-2">
    <div class="row">
        <div class="col-sm-12">
            <h4 class="h4 mt-3 mb-3" th:text="'欢迎您，'+${manager.managerName}"></h4>
        </div>
        <div class="col-sm-3">
            <div class="card card-success">
                <div class="card-header">
                    <div class="card-title">
                        可用余额
                    </div>
                    <div class="card-tools"></div>
                </div>
                <div class="card-body">
                    <h1 class="no-margins" th:text="${userAccount.balance} / 100 +' 元'"></h1>
                </div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="card">
                <div class="card-header">
                    <div class="card-title">
                        返现金额
                    </div>
                    <div class="card-tools">
                        <a class="btn btn-danger btn-xs" onclick="teacherTake()"><i class="fa fa-rmb"></i> 提现</a>
                    </div>
                </div>
                <div class="card-body">
                    <h1 class="no-margins" th:text="${userAccount.backAmount/100}+' 元'"></h1>
                </div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="card">
                <div class="card-header">
                    <div class="card-title">
                        充值金额
                    </div>
                    <div class="card-tools"></div>
                </div>
                <div class="card-body">
                    <h1 class="no-margins" th:text="${userAccount.vmAmount/100}+' 元'"></h1>
                </div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="card card-danger">
                <div class="card-header">
                    <div class="card-title">
                        冻结金额
                    </div>
                    <div class="card-tools"></div>
                </div>
                <div class="card-body">
                    <del><h1 class="text-red" th:text="${userAccount.frozenAmount/100}+' 元'">321</h1></del>
                </div>
            </div>
        </div>
    </div>
    <!-- Info boxes -->
    <div class="row">
        <div class="col-6 col-sm-4 col-lg-2">
            <div class="info-box">
				<span class="info-box-icon">
					<i class="fas fa-rss"></i>
				</span>
                <div class="info-box-content">
                    <span class="info-box-text">资讯</span>
                    <span class="info-box-number text-red">0</span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->
        <div class="col-6 col-sm-4 col-lg-2">
            <div class="info-box mb-3">
                <span class="info-box-icon"><i class="fas fa-audio-description"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">课程</span>
                    <span class="info-box-number text-red" th:text="${webCountMap.myCourseCount + ' 课'}">0</span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->

        <!-- fix for small devices only -->
        <div class="clearfix hidden-md-up"></div>

        <div class="col-6 col-sm-4 col-lg-2">
            <div class="info-box mb-3">
                <span class="info-box-icon"><i class="fas fa-user"></i></span>
                <div class="info-box-content">
                    <span class="info-box-text">学员</span>
                    <span class="info-box-number text-red" th:text="${webCountMap.myUserCount + ' 位'}">0</span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->
        <div class="col-6 col-sm-4 col-lg-2">
            <div class="info-box mb-3">
                <span class="info-box-icon"><i class="fa fa-first-order"></i></span>
                <div class="info-box-content">
                    <span class="info-box-text">总销量</span>
                    <span class="info-box-number text-red" th:text="${webCountMap.myOrderCount}">0</span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->
        <div class="col-6 col-sm-4 col-lg-2">
            <div class="info-box mb-3">
                <span class="info-box-icon"><i class="fas fa-users"></i></span>

                <div class="info-box-content">
                    <span class="info-box-text">
                        <a href="#" onclick="$.modal.openTab('教师订单', '/my/order/list.html');">
                            成交订单
                        </a>
                    </span>
                    <span class="info-box-number text-red" th:text="${webCountMap.myOrderSuccessCount}">0</span>
                </div>
                <!-- /.info-box-content -->
            </div>
            <!-- /.info-box -->
        </div>
        <!-- /.col -->
    </div>


    <div class="row">
        <div class="col-sm-12">
            <h4 class="h4 mt-3 mb-3">最近账户明细</h4>
        </div>
        <div class="col-sm-12">
            <table class="table table-hover no-margins">
                <thead>
                <tr>
                    <th>当前余额</th>
                    <th>现金余额</th>
                    <th>充值余额</th>
                    <th>交易金额</th>
                    <th>交易类型</th>
                    <th>业务类型</th>
                    <th style="width: 200px">时间</th>
                </tr>
                </thead>
                <tbody id="courseTbody"></tbody>
            </table>
        </div>
    </div>
</div>
<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: sparkline-js}" />
<th:block th:insert="~{include :: bootstrap-table-js}" />
<script  th:inline="javascript">
    var typ = [[${@dict.getType('qdx_acthistory_type')}]];
    var biz = [[${@dict.getType('qdx_acthistory_biz')}]];
    //添加课程
    function addCourse(channelId){
        $.modal.openTab('新增课程', '/course/add.html?channelId='+channelId);
    }

    $(function () {
        //最近课程
        $.post("/my/account/detail.json", {"limit": 6}, function (json) {
            var str = "";
            json.rows.forEach(function (value, index) {
                var orderAmount="";
                if(value.actHistoryType == "DRAWMONEY" || value.actHistoryType == "ADMINREFUND" || value.actHistoryType == "SALES"){
                    orderAmount = "<span style='color: red'>- "+value.orderAmount / 100+"</span>";
                }else {
                    orderAmount = "<span style='color: #008eff'>+ "+value.orderAmount / 100+"</span>";
                }
                str += "<tr>" +
                    "<td><small>" + (value.balance/100) + "</small></td>" +
                    "<td><small>" + (value.backAmount/100) + "</small></td>" +
                    "<td><small>" + (value.vmAmount/100) + "</small></td>" +
                    "<td><small>" + orderAmount + "</small></td>" +
                    "<td><small>" + $.table.selectDictLabel(typ, value.actHistoryType) + "</small></td>" +
                    "<td><small>" + $.table.selectDictLabel(biz, value.bizType) + "</small></td>" +
                    "<td><small>" + value.createTime + "</small></td>";
            })
            $("#courseTbody").empty().append(str);
        });
    })
    //教师提现
    function teacherTake() {
        $.modal.open("提现操作","/my/account/take.html", '800px', '600px');
    }
</script>
</body>
</html>
